<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>测试EL表达式</title>
</head>
<body>
<h1>测试EL表达式</h1>
<%
String name=request.getParameter("name");
String age=request.getParameter("age");
out.print("PageContext.PAGE_SCOPE="+PageContext.PAGE_SCOPE+"<br>");
pageContext.setAttribute("name", name, PageContext.PAGE_SCOPE);
pageContext.setAttribute("age", age, PageContext.PAGE_SCOPE);//(String name,Object value,int scope)
request.setAttribute("name", "李四");
request.setAttribute("age", 19);
session.setAttribute("name", "王五");
session.setAttribute("age", 20);
application.setAttribute("name", name);
application.setAttribute("age", age);
%>
\${1+2}=${1+2}<br>
\${null}=${null}<br>
\${name}=${name}<br>
\${age}=${age}<br>
\${sessionScope.name}=${sessionScope.name}<br>
<hr>
request.getRequestURL()=<%= request.getRequestURL()%><br>
\${pageContext.request.requestURL}=${pageContext.request.requestURL}
<hr>
session.getId()=<%= session.getId()%><br>
\${pageContext.session.id}=${pageContext.session.id}
<hr>
application.getServerInfo()=<%= application.getServerInfo()%><br>
\${pageContext.servletContext.serverInfo}=${pageContext.servletContext.serverInfo}
<hr>
\${param.name}=${param.name}<br>
\${param.age}=${param.age}<br>
\${param.ah}=${param.ah}<br>
\${paramValues.ah[0]}=${paramValues.ah[0]}<br>
\${paramValues.ah[1]}=${paramValues.ah[1]}<br>
\${paramValues.ah[2]}=${paramValues.ah[2]}
<hr>
\${header.Connection}=${header.Connection}<br>
\${header.User-Agent}=${header.User-Agent}<br>//由于User-Agent中的“-”符号被当做运算符，所以结果错误<br>
\${header['User-Agent']}=${header['User-Agent']}<br>//使用['XXX']解决了EL表达式中出现符号的问题
<hr>
\${cookie.JSESSIONID}=${cookie.JSESSIONID}<br>//不加.value时，则结果是获取了该cookie的对象地址<br>
\${cookie.JSESSIONID.value}=${cookie.JSESSIONID.value}<br>//加上.value时，则结果是获取了该cookie中的值
<hr>
\${initParam.name}=${initParam.name}
<hr>
\${17/5}=${17/5}<br>
<!-- \${17 div 5}=${17 div 5}<br> -->
\${17%5}=${17%5}<br>
<!-- \${17 mod 5}=${17 mod 5}<br> -->
                   
</body>
</html>